package com.qf;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
@MapperScan(basePackages="com.qf.mapper")
public class StartApp {
    public static void main(String[] args) {
        SpringApplication.run(StartApp.class, args);
    }
    @Bean
    public RestHighLevelClient restHighLevelClient(){
        //      创建 httphost 对象 获取 地址集端口
        HttpHost httpHost = new HttpHost("10.9.45.217", 9200, "http");
//       创建RestClientBuilder   客户端拿到了IP 地址
        RestClientBuilder builder = RestClient.builder(httpHost);
//      建立连接了
        RestHighLevelClient highLevelClient = new RestHighLevelClient(builder);
//      返回连接对象
        return highLevelClient;
    }

}
